package com.atguigu.gmall.feign.search;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.search.fallback.SkuEsFeignClientFallBack;
import com.atguigu.gmall.model.list.Goods;
import com.atguigu.gmall.model.list.SearchParam;
import com.atguigu.gmall.model.list.SearchResponseVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 检索服务的远程客户端
 * @author dyqstart
 * @create 2021-08-13-20:07
 * @since 1.0.0
 */
@FeignClient(value = "service-search",fallback = SkuEsFeignClientFallBack.class)
public interface SkuEsFeignClient {


    @PostMapping("/es/sku/inner/onsale")
    Result saveSkuToEs(@RequestBody Goods goods);

    @PostMapping("/es/sku/inner/canclesale/{skuId}")
    Result deleteSkuFromEs(@PathVariable("skuId") Long skuId);

    /**
     * 调用feign里对应的方法，
     * 此参数会转换成json，放到请求体里发送给远程
     * 远程查到的数据是json,feign把json转换成对应的返回值类型
     * @param searchParam
     * @return
     */
    @PostMapping("/es/sku/inner/search")
    Map<String,Object> searchGood(@RequestBody SearchParam searchParam);

    @GetMapping("/es/sku/inner/hotscore/{skuId}")
    Result updateSkuHotScore(@PathVariable("skuId") Long skuId,
                                    @RequestParam("hotscore") Long hotScore);
}
